<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    @include('public.h5_head')
    <title>待发布</title>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/rem.js"></script>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/common.css"/>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/shoplist.css?v=1.0.4"/>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/mobiscroll.core-2.5.2.css"  />
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/mobiscroll.android-ics-2.5.2.css"  />
    <style>
        .store .store_data .data_start{line-height: 1.664rem}
        #box_list .del_success{width:10rem;}
    </style>
</head>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/common.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/iscroll.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/app.js"></script>
<body onload="loaded()">
<div id="box_list">
    <div class="seek">
        <form action="" method="get">
            <div class="seek_img">
                <div class="seek_wrap">
                    <img class="seek_pic" src="/img/seek.png" alt="">
                    <input type="text" name="girard" autocomplete="off" autocorrect="off" class="seek_name" disabled value="{{ $girard }}" placeholder="搜索">
                </div>
            </div>
            <button type="submit" class="souBtn" style="display: none;">搜索</button>
        </form>
    </div>
    <div class="head">
        <div class="header_c"><span class="header_d car">待发布</span></div>
        <a href="/Business/producListRel"><div class="header_over"><span class="header_y">已发布</span></div></a>
    </div>
    <script>
        var detail_data=[
                @foreach($details as $info)
            [{{ $info->id }},{{ $info->produc_id }},'{{ $info->produc_type }}','{{ $info->produc_val }}',{{ $info->pid }}],
                @endforeach
            [-1,'','']
        ];
        function getGood(pro_id,type) {
            var val='default.png';
            for(var i=0;i<detail_data.length;i++)
            {
                if(detail_data[i][1]==pro_id && detail_data[i][2] == type && parseInt(detail_data[i][4])==0 ){
                    val =  detail_data[i][3];
                    break;
                }
            }
            return val;
        }

        function getGoodstock(pro_id,type) {
            var val = '';
            for(var i=0;i<detail_data.length;i++)
            {
                if(detail_data[i][1]==pro_id && detail_data[i][2] == type){
                    return  "<span  class=' pro_stock_"+detail_data[i][1]+"' title="+detail_data[i][3]+"></span>";
                }
            }
            return '';
        }
        function getGoodsval(pro_id,type) {
            for(var i=0;i<detail_data.length;i++)
            {
                if(detail_data[i][1]==pro_id && detail_data[i][2] == type){
                    return  "<span  class=' pro_price_"+detail_data[i][1]+"' title="+detail_data[i][3]+" ></span>";
                }
            }
            return '';
        }
        //获取衣服款式名称
        function getGoodcolor(pro_id,type) {
            var res = "";
            for(var i=0;i<detail_data.length;i++)
            {
                if(detail_data[i][1]==pro_id && detail_data[i][2]==type && parseInt(detail_data[i][4])==0 )
                    res += "<li class='product_model produc_color' title="+pro_id+" id="+detail_data[i][0]+">"+detail_data[i][3]+"</li>";
            }
            return res;
        }

        //是否可以发布
        function is_Release(pro_id) {
            for(var i=0;i<detail_data.length;i++)
            {
                if(detail_data[i][1]==pro_id && detail_data[i][2]=='color' && parseInt(detail_data[i][4])==0 )
                {
                    return "<img src='/img/00014.png'/>";
                }
            }
            return '';
        }

        $(document).on('click','.produc_color',function () {
            $('.produc_color').css('border','1px solid #bfbfbf');
            $(this).css('border','1px solid red');
            var pid =  $(this).attr('title');
            var id = $(this).attr('id');
            for(var i=0;i<detail_data.length;i++)
            {

                if(detail_data[i][4] == id && detail_data[i][2] == 'stock' && detail_data[i][1] == pid)
                {

                    $('.pro_stock_'+pid).text("数量:"+detail_data[i][3]);
                }
                if(detail_data[i][4] == id && detail_data[i][2] == 'price' && detail_data[i][1] == pid)
                {
                    $('.pro_price_'+pid).html("价格:<em>￥"+detail_data[i][3]+"</em>");
                }
            }
        });
    </script>
    <div class="wrap">
        <div class="main_list">
            <div class="store_over">
                <a href="/produc/index"><div class="add_infor">添加商品</div></a>
            </div>
            @foreach($lists as $list)
            <div class="store">
                <div class="store_icon">
					<img src="/img/00004.png" alt="" />
                    <span>
                        @if($list->brand == null)
                            暂未设置
                        @else
                            {{ $brands[$list->brand] }}
                        @endif
                    </span>
                    <div class="message"><a class="message_a" href="/Business/createPro/{{ $list->id }}">详细信息</a></div>
				</div>
                <div class="store_main">
                    <div class="storeDiv" id="{{ $list->id }}">
                        <div class="quan circle">
                            <img src="/img/00014.png"/>
                        </div>
                    </div>
                    <div class="store_pic">
                        <script>document.write("<img height='100%' width='100%' src='{{ env('CDN_DOMAIN_NAME') }}/upload/"+getGood('{{ $list->id }}','face')+"'/>");</script>
                    </div>
                    <div class="store_r">
                        @if($list->title)
                        <div class="storename">{{ $list->title }}</div>
                            <div class="productcolor">
                                <ul>
                                    <script>document.write(getGoodcolor('{{$list->id}}','color'));</script>
                                </ul>
                            </div>
                            <div class="store_id">款号:{{ $list->girard }}</div>
                            <div class="product_sp">
                                <div class="product_sum product_num">
                                    <script>document.write(getGoodstock('{{$list->id}}','stock'));</script>
                                </div>
                                <div class="product_price product_num">
                                    <script>document.write(getGoodsval('{{$list->id}}','price'));</script>
                                </div>
                            </div>
                            @else
                            <p style="font-size: 0.7rem">该商品尚未完善商品信息 </p>
                        @endif
                    </div>
                </div>
                <div class="store_data">
                    <input type="text"  readonly placeholder="抢购开始时间" abc="{{ $list->id }}" class="data_start data" id="appDateTime1" />
                    <span style="float:right;">所属：{{ $companys[$list->company_id] }}</span>
                    {{--<span class="store_across">-</span>--}}
                    {{--<input type="text"  readonly placeholder="抢购结束时间" class="data_end data" id="appDateTime2" />--}}

                </div>
            </div>
            @endforeach
            <input type="hidden" name="param" class="param" />
        </div>
    </div>
    <div class="footer_box">
        <div class="footer">
            <div class="footer_l">
                <div class="arrows">
                    <img src="/img/00014.png" alt="" />
                </div>
                <span>全选</span>
            </div>
            <div class="footer_r">
                <input type="button" value="删除" style="width:3rem" class="del_inp footer_btn" />
                <input type="button" value="复制" style="width:3rem;background:#1aad1a;color:#fff;float:left;margin-left:1.11rem;margin-top:0.299rem;cursor:pointer;" class="copy_inp footer_btn" />
                <input type="button" value="发布" style="width:3rem;cursor:pointer;" class="put_inp footer_btn" />
            </div>
        </div>
    </div>
    <div class="del_success" style="display: none;">删除成功</div>
    <meta name="csrf_token" id="token" content="{{ csrf_token() }}">
    @include('public.delete_tips')
</div>
</body>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/common.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/assets/produc_list_end.js"></script>
<script>
    is_weixn('.footer_box');
    /*iphoneX*/
    var str= navigator.userAgent.toLowerCase();
    var ver=str.match(/cpu iphone os (.*?) like mac os/);
    if(ver && $(window).width() === 375 && $(window).height() === 724 && window.devicePixelRatio === 3){
        $(".footer_box").css("height","3.499rem");
        $(".wrap").css("bottom","3.499rem");
    }
    /*滚动*/
    var myScroll;
    function loaded () {
        setTimeout(function(){
            myScroll = new IScroll('.wrap', {
                mouseWheel: true,
                click: true
            });
        },100);
    }
    document.addEventListener('touchmove', function (e) {e.preventDefault();},false);

    $(".seek").click(function(){
        $(".seek_img").css({"width":"13.5rem","float":"left"});
        $(".seek_wrap").css({"marginLeft":"0.5rem","width":"12.9rem"});
        $(".seek_name").css({"width":"12.3rem"});
        $(".seek_name").removeAttr("disabled");
        $(".seek_name").focus();
        $(".souBtn").show();
    })
    /*点击键盘backspace键清空重复密码*/
    $('.seek_name').keydown(function (event) {
        event=event||window.event;
        if (event.keyCode == 8) {
            console.log($('.seek_name').val().length);
            if($('.seek_name').val().length==1){
                $('.seek_name').val("");
                window.location.href='/Business/producList';
            }

        }
    });
//    $(".seek_name").blur(function(){
//        $(".seek_img").css({"width":"100%"});
//        $(".seek_wrap").css({"width":"2rem","margin":"0 auto"});
//        $(".seek_name").css({"width":"1.3rem"});
//        $(".seek_name").attr("disabled");
//        $(".souBtn").hide();
//    })
    /*点击复制*/
    $('.copy_inp').click(function () {
        var i = 0;
        $('.circle').each(function () {
            if($(this).children('img').attr('src') == '/img/00012.png'){
                i +=1;
            }
        });
        if( i >1 ){
            $('.del_success').text("只能勾选一个要复制的商品");
            $('.del_success').show(0).delay(1000).hide(0);
            return false;
        }
        if( i<=0 ){
            $('.del_success').text("请勾选一个要复制的商品");
            $('.del_success').show(0).delay(1000).hide(0);
            return false;
        }
        $('.copy_inp').attr('disabled','disabled');
        $('.circle').each(function () {
            if($(this).children('img').attr('src') == '/img/00012.png'){
                var id = $(this).parent('.storeDiv').attr('id');
                $.ajax({
                    url: '/business/copy-product-info/',
                    type: 'POST',
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                    },
                    data: {id:id,},
                    dataType: 'json',
                    success: function (data) {
                        if (data.result.success == true) {
                            window.location.href="/Business/createPro/"+data.content;
                        } else {
                            $('.copy_inp').removeAttr('disabled');
                            $('.del_success').text(data.result.errorMsg);
                            $('.del_success').show(0).delay(1000).hide(0);
                        }
                    }
                })
            }
        });
    });
</script>
</html>
